<template>
  <div id="vipcard">
    <vipcard-nav-bar />
    <vipcard-privilege :user="user" />
    <vipcard-open />
    <router-view :user="user"/>
  </div>
</template>

<script>
import VipcardNavBar from "./childComps/VipcardNavBar";
import VipcardPrivilege from "./childComps/VipcardPrivilege";
import VipcardOpen from "./childComps/VipcardOpen";

import { getUser } from "network/profile";
import { getPhysicalCard } from "network/vipcard";
export default {
  data() {
    return {
      user: {},
    };
  },
  created() {
    this.getUser(localStorage.getItem("user_id"));
  },
  mounted() {
    this.$bus.$on('handleExchange', data => {
      this.getPhysicalCard(localStorage.getItem('user_id'),data)
    })
  },
  methods: {
    getUser(user_id) {
      getUser(user_id).then((res) => {
        this.user = res;
      });
    },
    getPhysicalCard(user_id,data) {
      getPhysicalCard(user_id,data).then(res => {
        res.status ? '' : this.$toast.handleTipsText(res.message)
      })
    }
  },
  components: {
    VipcardNavBar,
    VipcardPrivilege,
    VipcardOpen,
  },
};
</script>
<style lang="less" scoped>
@import url('assets/css/mixin');
#vipcard {
  .initial-parent();
}
</style>